import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.SpringLayout;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class Clac {

	private JFrame frame;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Clac window = new Clac();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Clac() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		SpringLayout springLayout = new SpringLayout();
		frame.getContentPane().setLayout(springLayout);
		
		textField = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, textField, 48, SpringLayout.NORTH, frame.getContentPane());
		springLayout.putConstraint(SpringLayout.WEST, textField, 10, SpringLayout.WEST, frame.getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, textField, -369, SpringLayout.EAST, frame.getContentPane());
		frame.getContentPane().add(textField);
		textField.setColumns(10);
		
		JLabel lblConcentrationOf = new JLabel("% Concentration of sodium hypochlorite (on the side of the bottle)");
		springLayout.putConstraint(SpringLayout.WEST, lblConcentrationOf, 10, SpringLayout.WEST, frame.getContentPane());
		springLayout.putConstraint(SpringLayout.SOUTH, lblConcentrationOf, -6, SpringLayout.NORTH, textField);
		springLayout.putConstraint(SpringLayout.EAST, lblConcentrationOf, 350, SpringLayout.WEST, frame.getContentPane());
		frame.getContentPane().add(lblConcentrationOf);
		
		JLabel lblFinalConcentration = new JLabel("Final concentration (Should be 2 to 9)");
		springLayout.putConstraint(SpringLayout.NORTH, lblFinalConcentration, 6, SpringLayout.SOUTH, textField);
		springLayout.putConstraint(SpringLayout.WEST, lblFinalConcentration, 10, SpringLayout.WEST, frame.getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, lblFinalConcentration, 261, SpringLayout.WEST, frame.getContentPane());
		frame.getContentPane().add(lblFinalConcentration);
		
		textField_1 = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, textField_1, 6, SpringLayout.SOUTH, lblFinalConcentration);
		springLayout.putConstraint(SpringLayout.WEST, textField_1, 0, SpringLayout.WEST, textField);
		frame.getContentPane().add(textField_1);
		textField_1.setColumns(10);
		
		JLabel lblPpm = new JLabel("PPM");
		springLayout.putConstraint(SpringLayout.NORTH, lblPpm, 6, SpringLayout.SOUTH, lblFinalConcentration);
		springLayout.putConstraint(SpringLayout.WEST, lblPpm, 6, SpringLayout.EAST, textField_1);
		frame.getContentPane().add(lblPpm);
		
		JLabel label = new JLabel("%");
		springLayout.putConstraint(SpringLayout.NORTH, label, 0, SpringLayout.NORTH, textField);
		springLayout.putConstraint(SpringLayout.WEST, label, 6, SpringLayout.EAST, textField);
		frame.getContentPane().add(label);
		
		textField_2 = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, textField_2, 24, SpringLayout.SOUTH, textField_1);
		springLayout.putConstraint(SpringLayout.EAST, textField_2, 0, SpringLayout.EAST, textField_1);
		frame.getContentPane().add(textField_2);
		textField_2.setColumns(10);
		
		JLabel lblGal = new JLabel("gal");
		springLayout.putConstraint(SpringLayout.NORTH, lblGal, 0, SpringLayout.NORTH, textField_2);
		springLayout.putConstraint(SpringLayout.WEST, lblGal, 0, SpringLayout.WEST, lblPpm);
		frame.getContentPane().add(lblGal);
		
		JLabel lblResivoreSize = new JLabel("Resivore Size");
		springLayout.putConstraint(SpringLayout.NORTH, lblResivoreSize, 6, SpringLayout.SOUTH, textField_1);
		springLayout.putConstraint(SpringLayout.WEST, lblResivoreSize, 0, SpringLayout.WEST, textField);
		frame.getContentPane().add(lblResivoreSize);

		
		JLabel lblNewLabel = new JLabel("Dump this much bleach into your resivore");
		springLayout.putConstraint(SpringLayout.EAST, lblNewLabel, -109, SpringLayout.EAST, frame.getContentPane());
		frame.getContentPane().add(lblNewLabel);
		
		textField_3 = new JTextField();
		springLayout.putConstraint(SpringLayout.SOUTH, lblNewLabel, -6, SpringLayout.NORTH, textField_3);
		springLayout.putConstraint(SpringLayout.EAST, textField_3, 0, SpringLayout.EAST, lblFinalConcentration);
		textField_3.setEditable(false);
		frame.getContentPane().add(textField_3);
		textField_3.setColumns(10);

		
		JButton btnCalculate = new JButton("Calculate");
		springLayout.putConstraint(SpringLayout.NORTH, textField_3, 1, SpringLayout.NORTH, btnCalculate);
		btnCalculate.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				
				Float Precent =  Float.valueOf(textField.getText());
				Integer FinalConcentration = Integer.valueOf(textField_1.getText());
				Integer ResSize = Integer.valueOf(textField_2.getText());
				
				textField_3.setText(Float.toString( (FinalConcentration/(Precent*10000))*ResSize*3.785f*1000));
				
			}
		});
		springLayout.putConstraint(SpringLayout.NORTH, btnCalculate, 26, SpringLayout.SOUTH, textField_2);
		springLayout.putConstraint(SpringLayout.WEST, btnCalculate, 0, SpringLayout.WEST, textField);
		frame.getContentPane().add(btnCalculate);
		
	
		
		
		JLabel lblMl = new JLabel("ml");
		springLayout.putConstraint(SpringLayout.NORTH, lblMl, 3, SpringLayout.NORTH, textField_3);
		springLayout.putConstraint(SpringLayout.WEST, lblMl, 6, SpringLayout.EAST, textField_3);
		springLayout.putConstraint(SpringLayout.EAST, lblMl, -135, SpringLayout.EAST, frame.getContentPane());
		frame.getContentPane().add(lblMl);
	}
}
